package j73;

import java.lang.ref.SoftReference;

/**
 * @author chengshuai
 * @date 2021/4/18 12:54
 */
public class Test {


    /**
     * 内存够用的时候就保留，不够用回收！
     * @param args
     */
    public static void main(String[] args) {
        Object o1 = new Object();
        SoftReference<Object> reference = new SoftReference<>(o1);
        System.out.println(o1);
        System.out.println(reference.get());

        o1 = null;
        System.gc();

        System.out.println(o1);
        System.out.println(reference.get());
    }
}
